

//
//  ShopCartBottomBarView.m
//  ChineseCollegeStudentsNetwork
//
//  Created by 鹿达令 on 2019/3/23.
//  Copyright © 2019年 刘喆. All rights reserved.
//

#import "ShopCartBottomBarView.h"

@implementation ShopCartBottomBarView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.garyView];
        [self addSubview:self.checkButton];
        [self addSubview:self.allLabel];
        [self addSubview:self.totalLabel];
        [self addSubview:self.priceLabel];
        [self addSubview:self.accountButton];
        [self addSubview:self.garyView];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
 
  
    [_checkButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@20);
        make.width.equalTo(@20);
        make.left.equalTo(self.mas_left).offset(30);
        make.centerY.equalTo(self.mas_centerY);
        
    }];
 
    
    [_allLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.left.equalTo(self.checkButton.mas_right).offset(20);
        make.height.equalTo(@20);
        make.width.equalTo(@60);
    }];
    
    [_accountButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right);
        make.top.equalTo(self.mas_top);
        make.bottom.equalTo(self.mas_bottom);
        make.width.equalTo(@100);
    }];
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.right.equalTo(self.accountButton.mas_left).offset(10);
        make.height.equalTo(@20);
        make.width.equalTo(@100);
    }];
    
    [_totalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.right.equalTo(self.priceLabel.mas_left).offset(-5);
        make.width.equalTo(@40);
        make.height.equalTo(@20);
    }];
    
    [_garyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top);
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.height.equalTo(@(0.3));
    }];
}

- (UIButton *)checkButton {
    if (!_checkButton) {
        _checkButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_checkButton setImage:[UIImage imageNamed:@"选择2"] forState:UIControlStateNormal];
        [_checkButton setImage:[UIImage imageNamed:@"选中2"] forState:UIControlStateSelected];
    }
    return _checkButton;
}

-(UILabel *)allLabel {
    if (!_allLabel) {
        _allLabel = [[UILabel alloc]init];
        _allLabel.textColor = [UIColor lightGrayColor];
        _allLabel.font = [UIFont systemFontOfSize:15];
        _allLabel.text = @"全选";
    }

    return _allLabel;
}


-(UILabel *)totalLabel {
    if (!_totalLabel) {
        _totalLabel = [[UILabel alloc]init];
        _totalLabel.textColor = [UIColor blackColor];
        _totalLabel.font = [UIFont systemFontOfSize:15];
        _totalLabel.text = @"合计";
        _totalLabel.textAlignment = NSTextAlignmentRight;
    }
    
    return _totalLabel;
}

-(UILabel *)priceLabel {
    if (!_priceLabel) {
        _priceLabel = [[UILabel alloc]init];
        _priceLabel.textColor = [UIColor orangeColor];
        _priceLabel.font = [UIFont systemFontOfSize:15];
        _priceLabel.text = @"¥0";
    }
    
    return _priceLabel;
}

- (UIButton *)accountButton {
    if (!_accountButton) {
        _accountButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _accountButton.backgroundColor =[UIColor orangeColor];
        [_accountButton setTitle:@"结算" forState:UIControlStateNormal];
        [_accountButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _accountButton.titleLabel.font = [UIFont systemFontOfSize:15];
        
    }
    return _accountButton;
}

- (UIView *)garyView {
    if (!_garyView) {
        _garyView = [[UIView alloc]init];
        _garyView.backgroundColor = [UIColor lightGrayColor];
    }
    return _garyView;
}
@end
